/*
 * =====================================================================================
 *
 *       Filename:  alarm.c
 *
 *    Description:  alarm and signal demo
 *
 *        Version:  1.0
 *        Created:  04/16/2012 02:48:39 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Zhiyi Wu (Z.W), zhiyiw@uoregon.edu
 *        Company:  University of Oregon
 *
 * =====================================================================================
 */

#include	"stdio.h"
#include<unistd.h>
#include<signal.h>
void handler() { //you need to implement the signal handler
	printf("This is the event!\n");
}
main()
{
	int i;
	signal(SIGALRM,handler); //call the handler when receive the alarm.
	alarm(5); // send the alarm in 5 seconds.
wait();

//    printf( "%d\n",SIGALRM);
for(i=1;i<7;i++){
		printf("sleep %d ...\n",i);
		sleep(1);// wait for 1 second.
	}

}
